#coding=utf-8

import epics
import tornado
from controller.BaseHandler import BaseHandler
from controller import cagetDouble

class Handler(BaseHandler):

    @tornado.web.asynchronous
    @tornado.gen.coroutine
    def get(self):

        # 返回内容
        self.tplAssigns['boolValues'] = []
        self.tplAssigns['TPS1_OK'] = yield self.backend.submit(epics.caget, 'EXP_TB_HC:TPS1:TPS1_OK:SW:bo')
        self.tplAssigns['Hyd_READY'] = yield self.backend.submit(epics.caget, 'EXP_TB_HC:TPS1:Hyd_READY:SW:bi')
        self.tplAssigns['Hyd_LOCK'] = yield self.backend.submit(epics.caget, 'EXP_TB_HC:TPS1:Hyd_LOCK:SW:bi')
        self.tplAssigns['WATER_OK'] = yield self.backend.submit(epics.caget, 'EXP_TB_HC:TPS1:WATER_OK:SW:bi')
        self.tplAssigns['WATER_LOCK'] = yield self.backend.submit(epics.caget, 'EXP_TB_HC:TPS1:WATER_LOCK:SW:bi')
        self.tplAssigns['HEV_READY'] = yield self.backend.submit(epics.caget, 'EXP_TB_HC:TPS1:HEV_READY:SW:bi')
        self.tplAssigns['HEV_LOCK'] = yield self.backend.submit(epics.caget, 'EXP_TB_HC:TPS1:HEV_LOCK:SW:bi')
        self.tplAssigns['TPS2_OK'] = yield self.backend.submit(epics.caget, 'EXP_TB_HC:TPS2:TPS2_OK:SW:bo')
        self.tplAssigns['HydPRS'] = yield self.backend.submit(cagetDouble, 'EXP_TB_HC:TPS2:HydPRS:PRS:ai')
        self.tplAssigns['Hyd_LOCK'] = yield self.backend.submit(cagetDouble, 'EXP_TB_HC:TPS2:Hyd_LOCK:SW:bi')

        self.render("ezca/tps.html", **self.tplAssigns)
